import { createApp } from 'vue'
import Taro from '@tarojs/taro'

import { store, useStore } from '@/stores'

import {
  List,
  Icon,
  Sticky,
  Avatar,
  Button,
  SearchBar,
  CellGroup,
  Form,FormItem,
  Cell,
  Input,
  Grid,
  GridItem,
  Image,
  Swiper,
  SwiperItem,
  Menu,
  MenuItem,
  OverLay,
  Popup,
  Empty,
  Tabbar, TabbarItem,
  Video,
  Tag,
  Badge,
  Switch,
  Checkbox,
  CheckboxGroup,
  DatePicker, Picker,
  Layout,Row,Col,
  Dialog
} from '@nutui/nutui-taro'
import '@nutui/nutui-taro/dist/styles/themes/default.scss'
import './app.scss'

const App = createApp({
  onShow() {}
  // 入口组件不需要实现 render 方法，即使实现了也会被 taro 所覆盖
})
App.use(List)
App.use(Icon)
App.use(Sticky)
App.use(Avatar)
App.use(Button)
App.use(SearchBar)
App.use(Form)
App.use(FormItem)
App.use(CellGroup)
App.use(Cell)
App.use(Input)
App.use(Grid)
App.use(GridItem)
App.use(Image)
App.use(Swiper)
App.use(SwiperItem)
App.use(Menu);
App.use(MenuItem);
App.use(OverLay);
App.use(Popup);
App.use(Empty);
App.use(Tabbar);
App.use(TabbarItem);
App.use(Video);
App.use(Tag);
App.use(Badge);
App.use(Switch);
App.use(Checkbox);
App.use(CheckboxGroup);
App.use(DatePicker);
App.use(Picker);
App.use(Dialog);
App.use(Layout);
App.use(Row);
App.use(Col);

App.use(store)

// const auth = useStore('auth')
// const app = useStore('app')

// const token = Taro.getStorageSync('token')
// if (!token) {
//   auth.logout()
// } else {
//   app.startScreenLoading()
//   setTimeout(() => {
//     auth.setUserInfo({
//       nickName: '林qwe',
//       avatarUrl:
//         'https://img12.360buyimg.com/imagetools/jfs/t1/143702/31/16654/116794/5fc6f541Edebf8a57/4138097748889987.png'
//     })
//     auth.login()
//     app.cancelScreenLoading()
//   }, 500)
// }

export default App
